import { Ref, ref, onMounted, watch } from 'vue'
import { User } from '../entities'

export default function useUserRepositories(user: Ref<string>) {
    const repositories = ref([] as User[])
    const getUserRepositories = async () => {
        repositories.value = [{ name: user.value }]
    }

    onMounted(getUserRepositories)
    watch(user, getUserRepositories)

    return {
        repositories,
        getUserRepositories
    }
}